package com.myCinema.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.myCinema.dao.impl.CategoryDaoImpl;
import com.myCinema.entity.Category;
import com.myCinema.struts2.Action;

public class CateSaveAction implements Action{

	public String execute(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String name = request.getParameter("name");
		if(name !=null && !name.isEmpty()){
			Category c = new Category(0, name);
			new CategoryDaoImpl().save(c);
			return "success";
//			response.sendRedirect("CateList.action");
		}else{
			request.setAttribute("error", "添加失败");
			return "error";
//			request.getRequestDispatcher("categorySave.jsp").forward(request, response);
		}
		
	}

}
